package cn.tedu.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController //这个类是controller层的代码+可以接受浏览器发来的请求
@RequestMapping("/car4") //和地址栏里的url匹配
public class Car4Controller {
    //地址栏:http://localhost:8080/car4/get3/1/10
    //{id}是restful的特殊语法: 从地址栏里获取参数的值
    @RequestMapping("/get3/{id}/{age}")
    public String get3(
            //获取{id}里id的值
            @PathVariable int id,
            @PathVariable int age) {
        //给浏览器做出响应,结果展示在页面上
        return id+""+age;
    }
    @RequestMapping("/get2") //和地址栏里的url匹配
    public String get2(int id,int age) {
        // http://localhost:8080/car4/get2?id=2&age=88
        //给浏览器做出响应,结果展示在页面上
        return id+""+age;
    }
    @RequestMapping("/get")
    //http://localhost:8080/car4/get
    public String get(){
        return "abc";
    }
}
